/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tv.inventario.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import tv.inventario.modelo.EstructuraTipoProducto;

/**
 *
 * @author ctrosch
 */
@Stateless
public class EstructuraTipoProductoDAO {

        protected EntityManager em;

    @PersistenceContext(unitName="logic")
    public void setEm(EntityManager em){
	this.em = em;
    }

    public EntityManager getEm(){
        return this.em;
    }

    public List<EstructuraTipoProducto> getLista(){

        try {
            Query q = (Query) getEm().createQuery("select object(o) from EstructuraTipoProducto as o");
            return q.getResultList();
        }catch(Exception e){
            e.printStackTrace();
            System.out.println("No se puede obtener la lista de EstructuraTipoProducto" );
            return null;
        }
    }
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
 
}
